package org.hhgzs.modules.erp.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.hhgzs.modules.erp.entity.Account;
import org.hhgzs.modules.erp.entity.Material;
import org.hhgzs.modules.erp.entity.MaterialProperty;
import org.hhgzs.modules.erp.service.MaterialPropertyService;
import org.hhgzs.modules.erp.service.MaterialService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.PermissionData;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 产品扩展字段表 前端控制器
 * </p>
 *
 * @author peiqy
 * @since 2021-07-14
 */
@RestController
@RequestMapping("/materialProperty")
@Slf4j
@RequiredArgsConstructor
@Api("结算账户管理")
public class MaterialPropertyController extends JeecgController<MaterialProperty, MaterialPropertyService> {
    private final MaterialPropertyService materialPropertyService;
    /**
     * 获取用户列表数据
     *
     * @param data
     * @param pageNo
     * @param pageSize
     * @param req
     * @return
     */
    @PermissionData(pageComponent = "basedata/DepotList")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation("列表查询")
    public Result<IPage<MaterialProperty>> queryPageList(MaterialProperty data, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
        Result<IPage<MaterialProperty>> result = new Result<IPage<MaterialProperty>>();
        QueryWrapper<MaterialProperty> queryWrapper = QueryGenerator.initQueryWrapper(data, req.getParameterMap());

        Page<MaterialProperty> page = new Page<MaterialProperty>(pageNo, pageSize);
        IPage<MaterialProperty> pageList = materialPropertyService.page(page, queryWrapper);

        result.setSuccess(true);
        result.setResult(pageList);
        log.info(pageList.toString());
        return result;
    }


}
